<template>
	<view>
		<view class="" style="height: 100rpx;background-color: #fff;"></view>
		<view class="order_top">
			<image src="@/static/msgTop.png" mode="aspectFill" class="order_topImg"></image>
			<view class="order_tin">
				<image src="@/static/clrea.png" mode="aspectFill" style="width: 25rpx;height: 27rpx;"></image>
				<view class="order_tinSun" style="margin-left: 6rpx;">全部已读</view>
			</view>
		</view>
		<view class="tag_box">
			<view class="tag_boxSun" @click='management(0)'>
				<image src="@/static/linshen.png" mode="aspectFill" class="tagImg"></image>
				<view>服务通知</view>
			</view>
			<view class="tag_boxSun" @click='management(1)'>
				<image src="@/static/chiqiu.png" mode="aspectFill" class="tagImg"></image>
				<view>优惠活动</view>
			</view>
			<view class="tag_boxSun" @click='tourl'>
				<image src="@/static/kefu.png" mode="aspectFill" class="tagImg"></image>
				<view>客服中心</view>
			</view>
		</view>
		<view class="" style="height: 80rpx;"></view>
		<view class="" v-if="messageResult.length>0">
			<view class="msg_box" v-for="item in messageResult">
				<view>
					<image src="@/static/hread.png" mode="aspectFill"
						style="width: 92rpx;height: 92rpx;border-radius: 100%;"></image>
				</view>
				<view class="msg_titleFlx">
					<view class="msg_titleSun">
						<view class="msg_titleSun_title">{{item.create_by}}</view>
						<view class="msg_titleSun_time">{{item.create_time}}</view>
					</view>
					<view class="msg_cont">{{item.headline}}</view>
				</view>
			</view>
			<view class="msg_line"></view>
		</view>
		<view class="meiyous" v-else>
			<image src="@/static/meiyou.png" mode="aspectFill" style="width: 319rpx;height:230rpx;"></image>
			<view class="">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import Header from '@/components/header/header.vue'
	import driver from '@/api/modules/driver.js'
	export default {
		data() {
			return {
				options: [{}, {}],
				messageResult: [],
				wd: 0
			}
		},
		methods: {
			tourl() {
				uni.navigateTo({
					url: '/pages/message/Customer'
				})
			},
			management(e) {
				if (e == 0) {
					uni.navigateTo({
						url: '/pages/message/serviceReminder/serviceReminder'
					})
				} else if (e == 1) {
					uni.navigateTo({
						url: '/pages/message/offers/offers'
					})
				}


			},
			rightClick() {
				driver.modifyMessageReadAll({}).then((res) => {
					uni.reLaunch({
						url: '/pages/message/message'
					})
				})
			},
			handleTime(t, read) {
				if (t != null) {
					var y = t.split(" ")[0];
					var date = new Date();
					var cdate = new Date(y);
					var h = t.split(" ")[1];
					var str = h.split(":")[0] + ":" + h.split(":")[1];
					switch (date.getDate() - cdate.getDate()) {
						case 0:
							str = "今天" + str;
							break;
						case 1:
							str = "昨天" + str;
							break;
						case 2:
							str = "前天 " + str;
							break;
						default:
							str = y + " " + str;
							break;
					}
					return str;
				} else {
					return "";
				}
			},
			wayClick(e) {
				driver.modifyMessageRead({
					messageId: e.message_id
				}).then((res) => {
					if (res.data.code == 200) {
						if (e.addstate == 4) {
							uni.navigateTo({
								url: '/subPackages/order/querenTwo/querenTwo?id=' + e.corresponding_id
							})
						} else if (e.addstate == 5) {
							uni.navigateTo({
								url: '/subPackages/order/MyOrderDetails/MyOrderDetails?id=' + e
									.corresponding_id
							})
						} else {
							var remark = "";
							remark = e.remark
							if (remark.indexOf("前往") > -1) {
								uni.navigateTo({
									url: '/subPackages/map/OrderNavigation/OrderNavigation?id=' + e
										.corresponding_id
								})
							} else {
								uni.navigateTo({
									url: '/subPackages/order/orderDetail/orderDetail?id=' + e
										.corresponding_id
								})
							}
						}
					}
				})
			}
		},
		created() {

		},
		onShow() {

			driver.queryDriverMessageAll().then((res) => {
				this.messageResult = [];
				if (res.data.code == 200) {
					this.messageResult = res.data.data;
				}
			})
		},
		components: {
			Header
		}
	}
</script>

<style lang="scss" scoped>
	.meiyous {
		text-align: center;
		margin-top: 100rpx;
	}

	.msg_line {
		width: 580rpx;
		height: 1rpx;
		background-color: #F0EFEF;
		margin-top: 44rpx;
		margin-left: 120rpx;
		margin-bottom: 30rpx;
	}

	.msg_cont {
		font-size: 24rpx;
		color: #AFAFAF;
		margin-left: 20rpx;
		margin-top: 20rpx;
	}

	.msg_titleSun_time {
		font-size: 24rpx;
		color: #AFAFAF;
	}

	.msg_box {
		width: 690rpx;
		margin-top: 20rpx;
		margin-left: 30rpx;
		display: flex;
		align-items: center;
	}

	.msg_titleSun_title {
		color: #262626;
		font-size: 32rpx;
		font-weight: 600;
	}

	.msg_titleSun {
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 560rpx;
		margin-left: 20rpx;
	}

	.order_top {
		width: 100%;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 40rpx;
		padding-top: 40rpx;
	}

	.order_tinSun {
		color: #6B6B6B;
		font-size: 24rpx;
	}

	.order_topImg {
		width: 156rpx;
		height: 38rpx;
		margin-left: 32rpx;
	}

	.order_tin {
		margin-left: 10rpx;
		display: flex;
		align-items: center;
		margin-right: 30rpx;
	}

	.tagImg {
		width: 92rpx;
		height: 92rpx;
	}

	.tag_boxSun {
		text-align: center;
		font-size: 28rpx;
		color: #262626;
	}

	.tag_box {
		display: flex;
		justify-content: space-between;
		width: 604rpx;
		margin: 0 auto;
		margin-top: 50rpx;
	}
</style>